package br.edu.sistemaacademico.command;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.sql.SQLException;
import java.util.List;

import br.edu.sistemaacademico.builder.HistoricoDAO;
import br.edu.sistemaacademico.pojo.Historico;

public class CommandHistorico extends UnicastRemoteObject implements Command, Serializable{

	HistoricoDAO historicoDao = new HistoricoDAO();
	public CommandHistorico() throws RemoteException{
		// TODO Auto-generated constructor stub
	}
	@Override
	public boolean alterar(Object o) {
		Historico historico = (Historico) o;
		try {
			historicoDao.alterar(historico);
		} catch (SQLException e) { return false;		}
		return true;
	}

	@Override
	public Object carregaObjeto(String condicao, String tabelasAdd) {
		try {
			return historicoDao.getObject(condicao, tabelasAdd);
		} catch (SQLException e) { e.printStackTrace(); }
		return null;
	}

	@Override
	public List<Object> carregar(String condicao, String tabelasAdd) {
		return historicoDao.getAll(condicao, tabelasAdd,"matricula");
	}

	@Override
	public boolean deletar(Object o) {
		Historico historico = (Historico) o;
		try {
			historicoDao.deletar(historico);
			return true;
		} catch (SQLException e) {e.printStackTrace(); return false;}
		
	}

	@Override
	public List<Object> getCampos() {
		return historicoDao.getCampos();
	}

	@Override
	public boolean gravar(Object o) {
		Historico historico = (Historico) o;
		try {
			historicoDao.gravar(historico);
		} catch (SQLException e) { return false;		}
		return true;
	}

	
}
